/**
 * 
 */
package de.akabahn.ebd.dbd;

import java.util.Observer;

import de.akabahn.ebd.dbd.impl.DBDAdapterImpl;
import de.akabahn.ebd.dbd.impl.DBDAdapterMock;
import de.akabahn.ebd.dbd.impl.DBDAdapterSimulation;

/**
 * Factory class to get an implementation of the <code>DBDAdapter</code>
 * interface.
 * 
 * @author Peter Eimann
 * @since 0.2
 * @version 1.0
 */
public final class DBDAdapterFactory {

	/**
	 * This class shouldn't be instantiated as it contains only static methods
	 */
	private DBDAdapterFactory() {
	}

	/**
	 * Return an implementation of the <code>DBDAdapter</code> interface which
	 * connects to default server and port values.
	 * 
	 * @param connectionObservers
	 *            The observer classes that want to get notified when the
	 *            connection status to the DBD server changes
	 * @return The implementation instance
	 * @see DBDAdapterImpl#DBDAdapterImpl(Observer...)
	 */
	public static DBDAdapter getImplementation(Observer... connectionObservers) {
		return new DBDAdapterImpl(connectionObservers);
	}

	/**
	 * Return an implementation of the <code>DBDAdapter</code> interface which
	 * connects to the passed server and port.
	 * 
	 * @param server
	 *            The server to connect to
	 * @param port
	 *            The port to connect to
	 * @param connectionObservers
	 *            The observer classes that want to get notified when the
	 *            connection status to the DBD server changes
	 * @return The implementation instance
	 * @see DBDAdapterImpl#DBDAdapterImpl(String, int, Observer...)
	 */
	public static DBDAdapter getImplementation(String server, int port, Observer... connectionObservers) {
		return new DBDAdapterImpl(server, port, connectionObservers);
	}

	/**
	 * Return an implementation of the <code>DBDAdapter</code> interface which
	 * simulates interface without any connection.
	 * 
	 * @return The simulation instance
	 */
	public static DBDAdapter getSimulation() {
		return new DBDAdapterSimulation();
	}

	/**
	 * Return a test implementation of the <code>DBDAdapter</code>
	 * interface that doesn't require a telnet connection but returns fix
	 * responses instead.
	 *
	 * @param connectionObservers
	 *            The observer classes that want to get notified when the
	 *            connection status to the telnet server changes
	 * @return The <code>DBDAdapter</code> implementation
	 * @see #getImplementation(Observer...)
	 */
	public static DBDAdapter getTestImplementation(Observer... connectionObservers) {
		return new DBDAdapterMock(connectionObservers);
	}
}
